package service.vod.utlis;

import com.aliyun.vod.upload.impl.UploadVideoImpl;
import com.aliyun.vod.upload.req.UploadVideoRequest;
import com.aliyun.vod.upload.resp.UploadVideoResponse;

public class UploadAndDeleteVideo {
    static String title="test2";//上传文件后的名称
    static String fileName="E:\\test.mp4";//上传本地文件的路径+文件名

    public static void main(String[] args) {
        UploadAndDeleteVideo.uploadVideo(title, fileName);
    }

    //上传本地视频,返回视频id
    public static void uploadVideo(String title,String fileName){
        UploadVideoRequest request = new UploadVideoRequest("LTAI4GKRg25GXxBVqfcKm31L","m7qbbWUPXbV5ma93aDGHEiwoAL0kYY", title, fileName);
        //可指定分片上传时每个分片的大小,默认为2M字节
        request.setPartSize(2*1024*1024L);
        //可指定分片上传时的 并发线程数,默认为1
        request.setTaskNum(1);
        //创建上传器
        UploadVideoImpl uploader = new UploadVideoImpl();
        UploadVideoResponse response = uploader.uploadVideo(request);
        System.out.println("RequestId="+response.getRequestId()+"\n");//请求视频点播服务的请求ID
        if (response.isSuccess()){
            System.out.println("VideoId="+response.getVideoId()+"\n");
        }else
        {   //如果设置回调URL无效，不影响视频上传，可以返回VideoId同时会返回错误码，其他情况上传失败时VideoId为空
            System.out.println("VideoId="+response.getVideoId()+"\n");
            System.out.println("ErrorCode="+response.getCode()+"\n");
            System.out.println("ErrorMessage="+response.getMessage()+"\n");
        }
    }

    //删除阿里云上的视频
}
